/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.shoppingsystem.view.editors;

import java.awt.Component;
import javax.swing.AbstractCellEditor;
import javax.swing.JFormattedTextField;
import javax.swing.JFormattedTextField.AbstractFormatterFactory;
import javax.swing.JTable;
import javax.swing.table.TableCellEditor;

/**
 *
 * @author Usuario
 */
public class JFormattedFieldCellEditor extends AbstractCellEditor implements TableCellEditor{

    private final javax.swing.JFormattedTextField formattedField = new javax.swing.JFormattedTextField();
    
    @Override
    public Object getCellEditorValue() {
        return formattedField.getValue();
    }

    @Override
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
        formattedField.setValue(value);
        return formattedField;
    }
    
    public void setFormatterFactory(AbstractFormatterFactory af){
        formattedField.setFormatterFactory(af);
    }
}
